package com.xiaotao.learn.thread.concurrent.cas;

import com.xiaotao.learn.thread.concurrent.cas.simple.NumberHandler;

import java.util.concurrent.atomic.AtomicLong;

public class AtomicHandler implements NumberHandler {
    private AtomicLong n = new AtomicLong();
    @Override
    public void increase() {
        n.incrementAndGet();
    }

    @Override
    public void decrease() {
        n.decrementAndGet();
    }

    @Override
    public long getValue() {
        return n.get();
    }

    @Override
    public void reset() {
        n.set(0);
    }
}
